<template>
  <div>
    <h2>显示会员的相关信息</h2>
    <div>
      <p>姓名：{{ userStore.userInfo.mName }}</p>
      <p>手机：{{ userStore.userInfo.mPhone }}</p>
      <p>身份证：{{ userStore.userInfo.mCard }}</p>
    </div>
    <table class="table table-bordered">
      <tr> 
        <td>id</td>
        <td>优惠券标题</td>
        <td>类型</td>
        <td>状态</td>
        <td>操作</td>
      </tr>
      <tr v-for="item in list"> 
        <td>{{ item.mdId }}</td>
        <td>{{ item.dTitle }}</td>
        <td>{{ item.dtName }}</td>
        <td>{{ item.mdState == false?'未使用':'已使用' }}</td>
        <td>
          <input type="button" value="去使用">
        </td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, onMounted } from 'vue';
import axios from 'axios';
import { useRouter, useRoute } from 'vue-router';
import { useUserStore } from '../stores/user';

const route = useRoute();
const router = useRouter();
const userStore = useUserStore();


let data:any = reactive({
  list:[]
})

let {list} = toRefs(data)

onMounted(()=>{
  getDiscountList()
})


const getDiscountList = ()=>{
  let obj = {
    Mid:userStore.userInfo.mId
  }
  axios({
    url:'/api/Test/GetMemberDiscount',
    method:'get',
    params:obj
  })
  .then(res=>{
    console.log(res);
    list.value = res.data.data
    
  })
  .catch(err=>{
    console.log(err);
    
  })
}

</script>

<style scoped></style>
